package efg.tasks;

import interfacesFerrovia.ControleFerrovia;
import efg.Train;

public class AccelerateTrainTask extends SchedulableTask {

	private Train train;
	private Float speed;
	private Boolean urgency;

	public AccelerateTrainTask(int scheduledTime, Train train, Float speed,
			Boolean urgency) {
		super(scheduledTime);
		assert (train != null);
		assert (speed != null);
		assert (speed > 0);
		assert (urgency != null);
		this.train = train;
		this.speed = speed;
		this.urgency = urgency;
	}

	public Train getTrain() {
		return train;
	}

	public Float getSpeed() {
		return speed;
	}

	public Boolean getUrgency() {
		return urgency;
	}

	@Override
	public void execute(ControleFerrovia railwayControl) {
		if(speed > train.getCurrentSpeed()) {
			railwayControl.acelerarComposicao(train.getId(), speed, urgency);
		}
	}
}
